import {request} from '@umijs/max';
import * as API from "@/services";
import {FrontJournalSubscribe, FrontJournalSubscribeDetail, FrontJournalSubscribePlanQueryParams, FrontPayRecord} from "@/services";


/** 期刊订阅计划 列表检索请求 */
export async function queryFrontJournalSubscribePlans(params: API.FrontJournalSubscribePlanQueryParams): Promise<API.RespListResult<API.FrontJournalSubscribePlan>> {
  return request('/api/v1/front/journal-subscribe/plan', {
    params,
  });
}

/** 期刊订阅计划 详情请求 */
export async function queryFrontJournalSubscribePlan(bizId: API.EntityId): Promise<API.RespResult<API.FrontJournalSubscribePlan>> {
  return request(`/api/v1/front/journal-subscribe/plan/${bizId}`);
}

/** 订阅请求 */
export async function subscribeJournal(data: API.JournalSubscribe_Request): Promise<API.RespResult<API.JournalSubscribe_Response>> {
  return request(`/api/v1/front/journal-subscribe/subscribe`, {
    method: "POST",
    data: {
      ...data,

    },
  });
}

/** 订阅退订请求 */
export async function unsubscribeJournal(bizId: API.EntityId): Promise<API.RespResult<boolean>> {
  return request(`/api/v1/front/journal-subscribe/${bizId}/unsubscribe`, {
    method: "POST",
  });
}

/**
 * 我的订阅记录
 */
export async function queryMineJournalSubscribes(params: API.FrontMineJournalSubscribeQueryParams): Promise<API.RespPageResult<API.FrontJournalSubscribe>> {
  return request(`/api/v1/front/journal-subscribe/subscribe`, {
    method: "GET",
    params,
  });
}
/**
 * 订阅详情
 */
export async function queryFrontJournalSubscribe(bizId: API.EntityId): Promise<API.RespResult<API.FrontJournalSubscribeDetail>> {
  return request(`/api/v1/front/journal-subscribe/subscribe/${bizId}`, {
    method: "GET",
  });
}

/** 根据订单号查询支付记录 **/
export async function queryFrontPayRecord(orderNo: string): Promise<API.RespResult<API.FrontPayRecord>> {
  return request(`/api/v1/front/journal-subscribe/${orderNo}/pay-record`, {
    method: "GET",
  });
}
